<?php
/**
 * The GotStudentActivity form, used for creation and edition
 * @package ModuleGestionUniversitaire
 * @version 1.0b
 */
?>

<form action="" method ="post" class="form-crud">
<table cellpadding="0" cellspacing="0" border="0" class="form">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle"><?php echo ($_GET['operation'] == 'edit') ? 'Activité universitaire #'.$gotstudentactivity->gotstudentactivityId : 'Nouvelle activité universitaire'; ?></h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for=studentactivity-contact>Contact :</label></td>
		<td class="form-crud-input"><input id="studentactivity-contact" type="text" name="studentactivity-contact" value="<?php echo $contact->lastname.' '.$contact->firstname; ?>" /></td>
		<td class="form-crud-label"><label for="studentactivity-company">Société :</label></td>
		<td class="form-crud-input"><input id="studentactivity-company" type="text" name="studentactivity-company" value="<?php echo $company->name; ?>" /></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="studentactivity-role">Rôle :</label></td>
		<td class="form-crud-input">
			<select id="studentactivity-role" name="studentactivity-role">
				<?php
				$studentactivity = new StudentActivity();
				$studentactivityList = $studentactivity->GetList(Array(Array('studentactivityId', '>', '0')), 'name');
				foreach ($studentactivityList as $studentactivity)
					echo '<option value="'.$studentactivity->studentactivityId.'"'.(($gotstudentactivity->studentactivityId == $studentactivity->studentactivityId) ? ' selected="selected"' : '').'>'.$studentactivity->name.'</option>';
				?>
			</select>
		</td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for=studentactivity-from>De :</label></td>
		<td class="form-crud-input"><input id="studentactivity-from" type="text" name="studentactivity-from" value="<?php echo $dateFrom; ?>" /></td>
		<td class="form-crud-label"><label for="studentactivity-to">À :</label></td>
		<td class="form-crud-input"><input id="studentactivity-to" type="text" name="studentactivity-to" value="<?php echo $dateTo; ?>" /></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="studentactivity-content">Description :</label></td>
		<td class="form-crud-input" colspan="3">
			<textarea id="studentactivity-content" rows="10" cols="10" name="studentactivity-content"><?php echo $studentactivity->description; ?></textarea>
		</td>
	</tr>
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Rémunération</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="studentactivity-remuntype">Périodicité :</label></td>
		<td class="form-crud-input">
			<select id="studentactivity-remuntype" name="studentactivity-remuntype">
				<?php
				foreach ($remun as $key => $item)
					echo '<option value="'.$key.'"'.(($remuneration->type == $key) ? ' selected="selected"' : '').'>'.$item.'</option>';
				?>
			</select>
		</td>
		<td class="form-crud-label"><label for="studentactivity-remunamount">Montant :</label></td>
		<td class="form-crud-input"><input id="studentactivity-remunamount" type="text" name="studentactivity-remunamount" value="<?php echo $remuneration->amount; ?>" class="moneyfield" /></td>
	</tr>
</table>
<br />
<input type="hidden" value="<?php echo $gotstudentactivity->contactId; ?>" name="studentactivity-contactId" />
<input type="hidden" value="<?php echo $gotstudentactivity->companyId; ?>" name="studentactivity-companyId" />
<input type="hidden" value="<?php echo $gotstudentactivity->remunerationId; ?>" name="studentactivity-remunerationId" />
<input type="hidden" value="<?php echo $gotstudentactivity->gotstudentactivityId; ?>" name="studentactivity-studentactivityId" />
<input type="hidden" value="<?php echo $_GET['operation']; ?>" name="studentactivity-operation" />
<a href="#" id="form-studentactivity" class="submit">Sauvegarder</a>

<?php if ($_GET['operation'] != 'add'): ?>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Documents</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input">
			<table cellpadding="0" cellspacing="0" border="0" class="documents">
			<?php
			$documentList = $gotstudentactivity->GetDocumentList();
			foreach ($documentList as $document) {
				$res  = '<tr>';
				$res .= '<td class="del"><a href="'.$document->documentId.'" class="delete-doc"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
				$res .= '<td><a href="'.$configuration['appdir'].'data/docs/'.$document->documentId.'.'.$document->extension.'" target="_blank" class="file">'.$document->filename.'.'.$document->extension.'</a></td>';
				$res .= '</tr>';
				echo $res;
			}
			?>
			</table>
		</td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="studentactivity-file-upload">Ajouter des fichiers :</label></td>
		<td class="form-crud-input"><input id="studentactivity-file-upload" name="studentactivity-file-upload" type="file" /></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"><a href="javascript:$('#studentactivity-file-upload').uploadifyUpload()" class="upload">Upload</a></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
</table>
<?php endif; ?>

</form>

<div id="result"></div>

<div id="select_contact" class="hidden"></div>
<div id="select_company" class="hidden"></div>